#include "GlassShatterInclude.hlsli"

float4 main(GlassShatterInputPS input) : SV_TARGET
{
	float4 diffuseColor = diffuseTexture.Sample(linearSampler, input.TexCoords);
	diffuseColor.a *= pow((time / fadeOutTime), 0.5f);

     float3 directionToLight = normalize(lightPosition - input.WorldPosition);
     float3 reflectionVector = normalize(reflect(-directionToLight, input.WorldNormal));
     float3 directionToCamera = normalize(eyePosition - input.WorldPosition);
     
     //calculate specular component
     float4 specular = float4(specularColor, 1.0f) *  
                       pow(saturate(dot(reflectionVector, directionToCamera)), 
                       specularPower);
	// Added a step() call to cull adding specular to transparent diffuse.
	return saturate(diffuseColor + (specular * step(0.0001f, diffuseColor.a)));
}
